package com.boss.controller;

import com.alibaba.fastjson.JSON;
import com.boss.entity.BossAdmin;
import com.boss.entity.JobClassify;
import com.boss.service.JobClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//职业分类控制
@RestController
@RequestMapping("/jobClassify")
public class JobClassifyController {
    @Autowired
    private JobClassifyService jobClassifyService;

    /**
     * 获取职业分类方法,可重用
     * @param pid 父级编号,
     * @return 返回职业分类数据.
     */
    @RequestMapping("/getAllJobClassify")
    public String getAllJobClassify(@RequestParam(value = "parentId",required = false)String pid){
        Integer parentnum = null;//父级编号
        if(pid != null && !"".equals(pid)) {//判断编号是否合法
            parentnum = Integer.parseInt(pid);
        }
        List<JobClassify> list =  jobClassifyService.getAllJobClassify1(parentnum);
        String json =  JSON.toJSONString(list);
        return json;
    }
}
